uses crt;
const
Dimen= 50;
File_name='matrix.txt'; {//input file name}
var
i,j,n:integer;
mat:array [0..Dimen,0..Dimen] of real;{//matrix}
det:real;
procedure changecolmn( y:integer;x:integer); {//zeroing the upper triangular part of matrix}
var coefitient:real;i:integer;
begin
coefitient:=mat[y,x]/mat[y,y];
for i:=y to n-1 do mat[i,x]:=mat[i,x]-mat[i,y]*coefitient;
end;
procedure abnormal_read; {//called if the error while reading(oppening)}
begin
sound(440);
writeln(eoln,eoln,'\Error reading(or oppening) "',File_name,'" file');
writeln('check that you have been set the correct parameters');
writeln('at the first set the N and after that whole matrix e.g.',eoln);
writeln(' n');
writeln(' a(1,1) ... a(1,n)');
writeln(' .................');
writeln(' a(n,1) ... a(n,n)');
writeln(' for example -');
writeln('2',eoln,'1 2.03',eoln,'3 0.01');
delay(400);
nosound;
end;
begin;
clrscr;
writeln('Modificarion of Determ Cpp, by zARh');
delay(500);
clrscr;
writeln('This program is compute the determinant of sqare matrix N x N (N<120)');
writeln('what is contained in the file of curent folder called "',File_name,'"');
assign (input,File_name);{//oppening file}
{I-}
reset(input);
{I+}
if IOResult=0 {//chaking that the file is normaly oppened}
then
begin
writeln;
writeln('curent matrix is - ');
read(n);{//reading matrix`s dimension}
for i:=0 to n-1 do
begin
for j:=0 to n-1 do {// reading matrix}
begin read(mat[i][j]);
write(mat[i][j]:8:3);
end;
writeln;
end;
end
else abnormal_read; { //if file is NOT normaly readed}
for i:=0 to n-2 do {// THE MAIN PART}
for j:=i+1 to n-1 do {// sorting matrix}
changecolmn(i,j); {// THE MAIN PART !!!!!!!!!!}
det:=1.0;
for i:=0 to n-1 do det:=det*mat[i,i]; {//compute determinant}
write(' det=',det);
delay(3000)
end.